package com.edu.exam.enums.grading;

/**
 * 统计单位枚举
 */
public enum StatUnit {
    COUNT("COUNT", "个数"),
    PERCENTAGE("PERCENTAGE", "百分比"),
    MINUTES("MINUTES", "分钟"),
    HOURS("HOURS", "小时"),
    DAYS("DAYS", "天数"),
    SCORE("SCORE", "分数");

    private final String code;
    private final String description;

    StatUnit(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static StatUnit fromCode(String code) {
        for (StatUnit unit : values()) {
            if (unit.getCode().equals(code)) {
                return unit;
            }
        }
        return COUNT; // 默认返回个数
    }
}